home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
edit
/
aaem95ma.zip
/
FINDMODE.CC
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-19
|
3KB
|
70 lines
#include <std.h>
#include <pc.h>
#include <stdio.h>
#define byte unsigned char
#define uns unsigned
#define split(a,b,ab) ((a)=(ab)>>16,(b)=(ab)&0xffff)
long _ax=0,_bx=0,_cx=0,_dx=0,_si=0,_di=0,_sp=0; short _flags; void* _bp=0;
#define _al (*((byte*)&_ax))
#define _bl (*((byte*)&_bx))
#define _cl (*((byte*)&_cx))
#define _dl (*((byte*)&_dx))
#define _ah (*(((byte*)&_ax)+1))
#define _bh (*(((byte*)&_bx)+1))
#define _ch (*(((byte*)&_cx)+1))
#define _dh (*(((byte*)&_dx)+1))
#define _carry (_flags&1)
#define _zeroflag (_flags&0x40)
#define declint(n) \
void int##n(){asm("pushf"); asm("movl %ebp,__bp"); asm("movl %esp,__sp"); \
asm("xchgl __ax,%eax"); asm("xchgl __bx,%ebx"); asm("xchgl __cx,%ecx"); \
asm("xchgl __dx,%edx"); asm("xchgl __si,%esi"); asm("xchgl __di,%edi"); \
asm("int $0x"#n); asm("pushf"); asm("popw __flags"); \
asm("xchgl __ax,%eax"); asm("xchgl __bx,%ebx"); asm("xchgl __cx,%ecx"); \
asm("xchgl __dx,%edx"); asm("xchgl __si,%esi"); asm("xchgl __di,%edi"); \
asm("xchgl __bp,%ebp"); asm("xchgl __sp,%esp"); asm("popf");}
/*-----*/
declint(10); declint(11); declint(12); declint(13); declint(14); declint(15);
declint(16); declint(17); declint(18); declint(19); declint(1a); declint(21);
declint(25); declint(26); declint(27); declint(2f); declint(33); declint(67);
/*----- = current screen mode */
int gp_mode(void) {_ax=0xf00; int10(); return _ax&255;}
/*----- screen mode := m */
int gp_mode(char m) {_ax=m&255; int10(); return gp_mode();}
/*-----*/
int __; /* dustbin if int* arg not wanted */
int setscreenmode(byte md,int*ncols=&__,int erasescr=1){
_ah=0; _al=md|(erasescr?0:128); int10();
_ah=0xf; int10(); *ncols=_ah; return _al-(md&127);} /* 0 = OK */
byte getscreenmode(int*ncols=&__,int*pag=&__){
_ah=0xf; int10(); *ncols=_ah; *pag=_bh; return _al;}
/*-----*/
main(int nargs,char**arg){int i,n,m=getscreenmode(),M[256]; char s[128];
printf("screen mode = %2X hex = %3d decimal\n",m,m); if(nargs<2) exit(0);
strcpy(s,arg[1]); n=strlen(s);
for(i=0;i<n;i++) if(s[i]>='A') if(s[i]<='Z') s[i]+='a'-'A';
if(!strcmp(s,"all")) {
for(i=0;i<128;i=i==8?0xd:i+1) {setscreenmode(i); M[i]=getscreenmode()==i;}
setscreenmode(m); printf("screen modes:");
for(i=0;i<128;i++) if(M[i]) printf(" %2x",i); putchar('\n');}
else if(!strcmp(s,"text")) {int i,j,k,l,m,n,om,nm=0,p;
struct {uns short cols,rows; byte n,mono;} mode[128],*M=mode; byte*q;
om=gp_mode();
for(i=0;i<128;i=i==8?0xd:i+1) if(gp_mode(i),gp_mode()==i) {M->n=i;
M->cols=ScreenCols(); M->rows=ScreenRows();
outportb(0x3c0,0x10); j=inportb(0x3c1);
if(j&1) continue; /* graphics */ M->mono=(j&2)>>1; M++;}
gp_mode(om); nm=M-mode;
printf("mode cols rows\nhex text\n");
for(i=0;i<nm;i++) {M=mode+i;
printf(" %02x %3d %3d %4s\n",
M->n,M->cols,M->rows,
M->mono?"monochrome":"colour");}}
else if(sscanf(s,"%x",&i)) setscreenmode(i);
else {printf("I can't understand `%s'.\n",s);
printf("findmode all print numbers of all screen modes\n");
printf("findmode text print details of all screen text modes\n");
printf(\
"findmode nn set screen to mode nn, if nn is hex number (no `0x')\n");
printf("findmode with no arg, print what mode the screen is in now");}}